#include <ros/ros.h>
#include <turtlesim/Spawn.h>

int main(int arg, char **args)
{
    ros::init(arg, args, "turtle_spawn");

    ros::NodeHandle node;

    ros::service::waitForService("/spawn");
    ros::ServiceClient add_turtle = node.serviceClient<turtlesim::Spawn>("/spawn");

    turtlesim::Spawn srv;
    srv.request.x = 2.0;
    srv.request.y = 2.0;
    srv.request.name = "/turtle2";

    ROS_INFO("Call service to spawn turtle2[x:%0.6f, y:%0.6f, name:%s]", srv.request.x, srv.request.y, srv.request.name.c_str());

    add_turtle.call(srv);

    ROS_INFO("Spawn turtle sucessfully [name:%s]", srv.response.name.c_str());

    return 0;
}